#ifndef YCSB_C_PUREIO_H_
#define YCSB_C_PUREIO_H_

#include "../core/db.h"
#include <iostream>
#include <string>
#include "../core/properties.h"
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h> //write
#include <string.h> //memset

using std::cout;
using std::endl;

#define MAX_SOC_CNT 256

namespace ycsbc {

class PureIO:public DB{
    public:
        
        virtual void Init();
        PureIO()
        {
            cnt_ = 0;
        }
        ~PureIO(){
            for (int i = 0; i < cnt_;i++){
                shutdown(sockets[i], SHUT_RDWR);
            }
        }

        int Read(const std::string &table, const std::string &key,
           const std::vector<std::string> *fields,
           std::vector<KVPair> &result){
            io_();
            return DB::kOK;
        }

        int Scan(const std::string &table, const std::string &key,
           int len, const std::vector<std::string> *fields,
           std::vector<std::vector<KVPair>> &result) {
            throw "Scan: function not implemented!";
        }

        int Update(const std::string &table, const std::string &key,
                   std::vector<KVPair> &values) {return DB::kOK;}

        int Insert(const std::string &table, const std::string &key,
                   std::vector<KVPair> &values) {return DB::kOK;}

        int Delete(const std::string &table, const std::string &key) 
        {io_();return DB::kOK;}

    private:
        void io_();
        int cnt_;
        int sockets[MAX_SOC_CNT];
};

}


#endif